<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div id="app">
        <p v-if="flag">被v-if控制的元素</p>
        <p v-show="flag">被v-show控制的元素</p>
        <button @click="demoBtn">切换</button>
        <hr>
        <p>if-else结合</p>
        <div v-if="type === 'A'">显示A</div>
        <div v-else-if="type === 'B'">显示B</div>
        <div v-else>type={{type}}</div>
    </div>
    <script src="./lib/vue.js"></script>
    <script>
        const vm = new Vue({
            el: '#app',
            data: {
                flag: true,
                type: 'A'
            },
            methods: {
                demoBtn() {
                    if (this.flag === true) {
                        this.flag = false;
                    } else {
                        this.flag = true;
                    }
                }
            }
        })
    </script>
</body>

</html>